package com.qf.api.product.fallback;

import com.qf.api.product.feign.ProductFeignService;
import com.qf.common.core.entity.product.Product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * @author GaoQiangLiang
 * @date 2025-06-14 15:50
 */

@Component
@Slf4j
public class ProductFallbackFactory implements FallbackFactory<ProductFeignService> {


    @Override
    public ProductFeignService create(Throwable cause) {
        return new ProductFeignService() {
            @Override
            public List<Product>  getProductInfo(List<Integer> productIds) {
                log.error("调用商品服务失败:{}", cause);
                return Collections.emptyList();
            }

        };
    }
}
